Added an API point about needing a way to fetch the hpaned position so we
authorFederico Mena Quintero <federico@ximian.com>
Thu, 11 Sep 2003 00:56:46 +0000 (00:56 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Thu, 11 Sep 2003 00:56:46 +0000 (00:56 +0000)
2003-09-10  Federico Mena Quintero  <federico@ximian.com>

* TODO: Added an API point about needing a way to fetch the hpaned
position so we can save it.

* gtkfilechooser.c (_gtk_file_chooser_get_paths): Fixed API docs.
(gtk_file_chooser_get_uris): Likewise.
(gtk_file_chooser_get_filenames): Likewise.

* gtkfilechooserdialog.c (file_chooser_widget_file_activated): New
callback, calls gtk_window_activate_default().

* testfilechooser.c (response_cb): Print the selected files if the
user clicks OK.

gtk/gtkfilechooser.c
gtk/gtkfilechooserdialog.c
tests/testfilechooser.c

index f3046e75ecaa46bd5d5a7b8fa0719dcfb5a0791f..0153b23d55412bd5317c76a45d954e16fff4cb7e 100644 (file)
@@ -440,14 +440,14 @@ gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
  * gtk_file_chooser_get_filenames:
  * @chooser: a #GtkFileChooser
  * 
- * Lists all the files and subfolders in the current folder of
- * @chooser. The returned names are full absolute paths. If files
- * in the current folder cannot be represented as local filenames
- * they will be ignored. (See gtk_file_chooser_get_uris())
+ * Lists all the selected files and subfolders in the current folder of
+ * @chooser. The returned names are full absolute paths. If files in the current
+ * folder cannot be represented as local filenames they will be ignored. (See
+ * gtk_file_chooser_get_uris())
  * 
- * Return value: a #GList containing the filenames of all
+ * Return value: a #GSList containing the filenames of all selected
  *   files and subfolders in the current folder. Free the returned list
- *   with g_lists_free(), and the filenames with g_free().
+ *   with g_slist_free(), and the filenames with g_free().
  **/
 GSList *
 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
@@ -687,15 +687,15 @@ gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
 }
 
 /**
- * gtk_file_chooser_get_filenames:
+ * gtk_file_chooser_get_uris:
  * @chooser: a #GtkFileChooser
  * 
- * Lists all the files and subfolders in the current folder of
+ * Lists all the selected files and subfolders in the current folder of
  * @chooser. The returned names are full absolute URIs.
  * 
- * Return value: a #GList containing the URIs of all
+ * Return value: a #GSList containing the URIs of all selected
  *   files and subfolders in the current folder. Free the returned list
- *   with g_lists_free(), and the filenames with g_free().
+ *   with g_slist_free(), and the filenames with g_free().
  **/
 GSList *
 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
@@ -853,13 +853,12 @@ _gtk_file_chooser_unselect_path (GtkFileChooser    *chooser,
  * _gtk_file_chooser_get_paths:
  * @chooser: a #GtkFileChooser
  * 
- * Lists all the files and subfolders in the current folder of
- * @chooser as #GtkFilePath. An internal function, see
- * gtk_file_chooser_get_uris().
+ * Lists all the selected files and subfolders in the current folder of @chooser
+ * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
  * 
- * Return value: a #GList containing a #GtkFilePath for each
- *   files and subfolder in the current folder. Free the returned list
- *   with g_lists_free(), and the paths with gtk_file_path_free().
+ * Return value: a #GSList containing a #GtkFilePath for each selected
+ *   file and subfolder in the current folder.  Free the returned list
+ *   with g_slist_free(), and the paths with gtk_file_path_free().
  **/
 GSList *
 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
index 854783f19c82096e4a65dc92488a5cdc8eb9c1f0..77ab450240cd8322eb5f37d1d4d231ff467752bf 100644 (file)
@@ -114,6 +114,14 @@ gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
   dialog->priv = priv;
 }
 
+/* Callback used when the user activates a file in the file chooser widget */
+static void
+file_chooser_widget_file_activated (GtkFileChooser       *chooser,
+                                   GtkFileChooserDialog *dialog)
+{
+  gtk_window_activate_default (GTK_WINDOW (dialog));
+}
+
 static GObject*
 gtk_file_chooser_dialog_constructor (GType                  type,
                                     guint                  n_construct_properties,
@@ -135,6 +143,9 @@ gtk_file_chooser_dialog_constructor (GType                  type,
                                 NULL);
   else
     priv->widget = g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET, NULL);
+
+  g_signal_connect (priv->widget, "file-activated",
+                   G_CALLBACK (file_chooser_widget_file_activated), object);
   
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), priv->widget, TRUE, TRUE, 0);
   gtk_widget_show (priv->widget);
index 5ff9af1d2cdcc2c45c14ef324c2481fe8dee3873..be1127f9db70c1d19a21ef056e923261d92f0f0b 100644 (file)
@@ -50,6 +50,32 @@ static void
 response_cb (GtkDialog *dialog,
             gint       response_id)
 {
+  if (response_id == GTK_RESPONSE_OK)
+    {
+      GSList *list;
+
+      list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
+
+      if (list)
+       {
+         GSList *l;
+
+         g_print ("Selected files:\n");
+
+         for (l = list; l; l = l->next)
+           {
+             g_print ("%s\n", (char *) l->data);
+             g_free (l->data);
+           }
+
+         g_slist_free (list);
+       }
+      else
+       g_print ("No selected files\n");
+    }
+  else
+    g_print ("Dialog was closed\n");
+  
   gtk_main_quit ();
 }